﻿// ***********************************************************************
// Assembly         : INNOVACALL.Framework.Common
// Author           : LJO+01 (Laurent Jordi)
// Created          : 06-05-2013
// Last Modified By : LJO+01 (Laurent Jordi)
// Last Modified On : 06-05-2013
// ***********************************************************************
// <copyright file="Languages_MetaModel.cs" company="Copyright © Innovacall 2011">
//     Copyright (c) Copyright © Innovacall 2011. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Web;

namespace INNOVACALL.Framework.Common.Models.ViewModels.MetaModels
{
    /// <summary>
    /// Class Languages_MetaModel
    /// </summary>
    public class Languages_MetaModel
    {
        /// <summary>
        /// Gets the default language.
        /// </summary>
        /// <value>The default language.</value>
        public string DefaultLanguage
        {
            get
            {
                return ConfigurationManager.AppSettings["DefaultLanguage"];
            }
        }
        /// <summary>
        /// Gets or sets the languages.
        /// </summary>
        /// <value>The languages.</value>
        public List<Language_MetaModel> Languages { get; set; }
        /// <summary>
        /// Gets or sets the selected language.
        /// </summary>
        /// <value>The selected language.</value>
        public Language_MetaModel SelectedLanguage { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="Languages_MetaModel"/> class.
        /// </summary>
        public Languages_MetaModel()
        {
            this.Languages = new List<Language_MetaModel>();
            string[] tLanguages = ConfigurationManager.AppSettings["Languages"].Split(',');
            this.Languages = tLanguages.Select(x => new Language_MetaModel(x)).ToList();
            this.SelectedLanguage = this.Languages.Where(x => x.Language == this.DefaultLanguage).Single();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Languages_MetaModel"/> class.
        /// </summary>
        /// <param name="selectedLanguage">The selected language.</param>
        public Languages_MetaModel(string selectedLanguage)
        {
            this.Languages = new List<Language_MetaModel>();
            string[] tLanguages = ConfigurationManager.AppSettings["Languages"].Split(',');
            this.Languages = tLanguages.Select(x => new Language_MetaModel(x)).ToList();
            this.SelectedLanguage = this.Languages.Where(x => x.Language == selectedLanguage).Single();
        }
    }
}
